# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
  # include authentication subsystem from restful_authentication plugin
  include AuthenticatedSystem

  before_filter :set_current_blog
  
  protected
    def set_current_blog
      blog_name = params[:blog]
      if blog_name
        @current_blog = Blog.find_by_name(blog_name)
      else
        @current_blog = System.default_blog
      end
    end
    
    def current_blog
      @current_blog or raise "There is no current blog! This system probably does not have any blogs yet."
    end
    helper_method :current_blog
    
    def current_skin
      @current_blog.skin
    end
    helper_method :current_skin
end